﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WeiTap.Data.Attributes;

namespace WeiTap.Data.Test
{
    public static class DataManager
    {
        public static async Task<ArticelTag> GetTag(string name)
        {
            using (var db = new Sql003Database())
            {
                return await db.Single<ArticelTag>("select * from vinfo_Dyb_Tags where isactive=1 and name=@0", name);
            }
        }
        public static async Task<IList<ArticelTag>> GetAllTag(bool isActive)
        {
            using (var db = new Sql003Database())
            {
                return await db.FetchAsync<ArticelTag>("select * from vinfo_Dyb_Tags where isactive=@0", isActive);
            }
        }

        public static async Task<IList<WebSite>> GetAllWebSite(string tag)
        {
            using (var db = new Sql003Database())
            {
                return await db.FetchAsync<WebSite>($"select id,userid,tag_dyb from vIFO_Union_WebSite where tag_dyb like '%{tag},%'");
            }
        }

        public static async Task<int> UpdateWebSite(WebSite site)
        {
            using (var db = new Sql003Database())
            {
                return await db.UpdateAsync(site);
            }
        }
    }
}
